package com.vturkey.dao; 

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository("basicDao")
public abstract class BasicDao implements IBasicDao{
	
	@Autowired
	protected SessionFactory factory;
	
	public void save(Object o) {
		Session session = factory.openSession();
		session.saveOrUpdate(o);
		session.flush();
		session.close();
	}
	
	public void delete(Object o) {
		Session session = factory.openSession();
		session.delete(o);
		session.flush();
		session.close();
	}
	
	public void update(Object o) {
		Session session = factory.openSession();
		session.update(o);
		session.flush();
		session.close();
	}
	
}
